home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
5,555 MP3 Music & Sound
/
5,555 MP3 - Music & Sound.iso
/
pro
/
musict~1.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2000-03-01
|
19KB
|
771 lines
unit musictest;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
MPlayer, FileCtrl, StdCtrls, ExtCtrls, Buttons, Menus, shellapi,
CoolTrayIcon, ImgList, ComCtrls, MPEGPlay, OleCtrls, MediaPlayer_TLB;
type
TWebM = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
DirectoryListBox1: TDirectoryListBox;
Panel5: TPanel;
Timer1: TTimer;
MainMenu1: TMainMenu;
File1: TMenuItem;
Close1: TMenuItem;
N1: TMenuItem;
About1: TMenuItem;
BDGPubishingInc1: TMenuItem;
ShoponCD1: TMenuItem;
InstallNetscape1: TMenuItem;
Install1: TMenuItem;
Panel6: TPanel;
repeatm: TSpeedButton;
cti: TCoolTrayIcon;
ImageList4: TImageList;
PopupMenu1: TPopupMenu;
ShowWindow1: TMenuItem;
HideWindow1: TMenuItem;
MenuItem1: TMenuItem;
Exit1: TMenuItem;
View1: TMenuItem;
MinimizetoIcon1: TMenuItem;
ExploreCurrentFolder1: TMenuItem;
all: TSpeedButton;
intro: TSpeedButton;
Timer3: TTimer;
WindowsDesktop1: TMenuItem;
SpeedButton1: TSpeedButton;
SaveList1: TMenuItem;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
OpenList1: TMenuItem;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
GB1: TGroupBox;
FileListBox1: TFileListBox;
GroupBox1: TGroupBox;
ListBox1: TListBox;
savb: TSpeedButton;
SpeedButton6: TSpeedButton;
ListBox2: TListBox;
ran: TSpeedButton;
SpeedButton7: TSpeedButton;
N2: TMenuItem;
OpenMediaFile1: TMenuItem;
N3: TMenuItem;
Playlist1: TMenuItem;
Directory1: TMenuItem;
Panel4: TPanel;
ei: TSpeedButton;
ea: TSpeedButton;
pb: TSpeedButton;
CheckBox1: TCheckBox;
SpeedButton4: TSpeedButton;
SpeedButton8: TSpeedButton;
TheBestMusicMatch1: TMenuItem;
PopupMenu2: TPopupMenu;
Copy1: TMenuItem;
N5: TMenuItem;
cdf: TMenuItem;
SetDefaultFolder1: TMenuItem;
sm1: TMenuItem;
Readme1: TMenuItem;
ExploreCD1: TMenuItem;
cb1: TComboBox;
MediaPlayer2: TMenuItem;
ms: TMSMediaPlayer;
Panel7: TPanel;
DriveComboBox1: TDriveComboBox;
procedure DriveComboBox1Change(Sender: TObject);
procedure DirectoryListBox1Change(Sender: TObject);
procedure chktemp(dir:string; var re:string);
procedure mediap(filen:string);
procedure FileListBox1DblClick(Sender: TObject);
procedure eiClick(Sender: TObject);
procedure eaClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure Close1Click(Sender: TObject);
procedure BDGPubishingInc1Click(Sender: TObject);
procedure InstallNetscape1Click(Sender: TObject);
procedure ShoponCD1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure pbClick(Sender: TObject);
procedure MinimizetoIcon1Click(Sender: TObject);
procedure ShowWindow1Click(Sender: TObject);
procedure HideWindow1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure ctiMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure ExploreCurrentFolder1Click(Sender: TObject);
procedure allClick(Sender: TObject);
procedure Timer3Timer(Sender: TObject);
procedure FileListBox1Change(Sender: TObject);
procedure introClick(Sender: TObject);
procedure WindowsDesktop1Click(Sender: TObject);
procedure SaveList1Click(Sender: TObject);
procedure OpenList1Click(Sender: TObject);
procedure MediaPlayer1Notify(Sender: TObject);
procedure chkcon;
procedure sb1Scroll(Sender: TObject; ScrollCode: TScrollCode;
var ScrollPos: Integer);
procedure mp3PlayEnd(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
procedure savbClick(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure ListBox2Enter(Sender: TObject);
procedure ranClick(Sender: TObject);
procedure SpeedButton7Click(Sender: TObject);
procedure Directory1Click(Sender: TObject);
procedure Playlist1Click(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure TheBestMusicMatch1Click(Sender: TObject);
procedure MP3toWav1Click(Sender: TObject);
procedure DirectoryListBox1Click(Sender: TObject);
procedure cdfClick(Sender: TObject);
procedure SetDefaultFolder1Click(Sender: TObject);
procedure ExploreCD1Click(Sender: TObject);
procedure Readme1Click(Sender: TObject);
procedure cb1Change(Sender: TObject);
procedure MediaPlayer2Click(Sender: TObject);
procedure FileListBox1Click(Sender: TObject);
procedure msEndOfStream(Sender: TObject; Result: Integer);
procedure FormShow(Sender: TObject);
procedure msPlayStateChange(Sender: TObject; OldState,
NewState: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
const
ModeStr: array[TMPModes] of string = ('Not ready', 'Stopped', 'Playing', 'Recording', 'Seeking', 'Paused', 'Open');
var
WebM: TWebM;
tempstr,cur,masterdir:string;
orifile,desfile,loadbmp:array[0..255] of char;
music,conm:integer;
rep:boolean;
ormouse,desmouse:tpoint;
fhg,fhd,fphy:integer;
implementation
uses di;
{$R *.DFM}
procedure TWebM.DriveComboBox1Change(Sender: TObject);
begin
directorylistbox1.Drive:=drivecombobox1.Drive;
end;
procedure TWebM.DirectoryListBox1Change(Sender: TObject);
begin
filelistbox1.Directory:=directorylistbox1.Directory;
end;
procedure TWebM.chktemp(dir:string; var re:string);
begin
if dir[length(dir)]<>'\' then dir:=dir+'\';
re:=dir;
end;
procedure TWebM.FileListBox1DblClick(Sender: TObject);
var i,j:integer;
begin
chktemp(filelistbox1.directory,tempstr);
j:=0;
for i:=0 to filelistbox1.items.count-1 do
if filelistbox1.Selected[i] then
begin
j:=1;
break;
end;
if j=0 then exit else
begin
if listbox2.items.count>0 then
for j:=0 to listbox2.items.count-1 do
if listbox2.items[j]=tempstr+filelistbox1.items[i] then
if MessageDlg('There is a duplicate file inthe list box, do you want to add anyway?',
mtConfirmation, [mbYes, mbNo], 0) = mrNo then exit;
listbox2.Items.Add(tempstr+filelistbox1.items[i]);
listbox1.items.add(tempstr+filelistbox1.items[i]);
end;
end;
procedure TWebM.eiClick(Sender: TObject);
var i,j:integer;
begin
if listbox1.Items.count>0 then
for i:=0 to listbox1.items.count-1 do
if listbox1.selected[i] then
begin
for j:=0 to listbox2.items.count-1 do
if listbox2.items[j]=listbox1.items[i] then
begin
listbox2.Items.Delete(j);
break;
end;
listbox1.Items.delete(i);
break;
end;
end;
procedure TWebM.eaClick(Sender: TObject);
begin
listbox1.Clear;
listbox2.Clear;
end;
procedure TWebM.Timer1Timer(Sender: TObject);
begin
cdf.Enabled:=sm1.Enabled;
cti.Hint:='Current playing '+ms.FileName;
ShowWindow1.Enabled:=not visible;
HideWindow1.Enabled:=visible;
if filelistbox1.Items.count<=0 then
begin
savb.Enabled:=false;
all.Enabled:=false;
intro.Enabled:=false;
sm1.Enabled:=false;
end else begin
all.Enabled:=true;
intro.Enabled:=true;
end;
if listbox1.Items.count<=0 then
begin
ea.enabled:=false;
ei.enabled:=false;
pb.Enabled:=false;
repeatm.enabled:=false;
ran.Enabled:=false;
end else
begin
repeatm.enabled:=true;
ran.Enabled:=true;
ea.enabled:=true;
if pb.Tag=0 then
pb.enabled:=true;
end;
end;
procedure TWebM.ListBox1Click(Sender: TObject);
var i:integer;
begin
for i:=0 to listbox1.items.count-1 do
if listbox1.selected[i] then ei.Enabled:=true;
end;
procedure TWebM.Close1Click(Sender: TObject);
begin
close;
end;
procedure TWebM.BDGPubishingInc1Click(Sender: TObject);
begin
ordi.showmodal;
end;
procedure TWebM.InstallNetscape1Click(Sender: TObject);
begin
strpcopy(orifile,cur+'cc47.exe');
winexec(orifile,sw_shownormal);
end;
procedure TWebM.ShoponCD1Click(Sender: TObject);
begin
strpcopy(orifile,'1.htm');
strpcopy(desfile,cur);
findexecutable(orifile,desfile,loadbmp);
tempstr:=' http://www.shop4all.com';
strpcopy(orifile,loadbmp+tempstr);
winexec(orifile,sw_shownormal);
end;
procedure TWebM.FormCreate(Sender: TObject);
begin
getwindowsdirectory(orifile,200);
chktemp(orifile,masterdir);
getdir(0,cur);
chktemp(cur,cur);
music:=-1;
fphy:=height;
Directory1Click(Sender);
playlist1click(sender);
masterdir:=cur;
end;
procedure TWebM.pbClick(Sender: TObject);
begin
timer3.enabled:=false;
music:=0;
pb.Tag:=1;
pb.Enabled:=false;
mediap(listbox1.items[music]);
end;
procedure TWebM.MinimizetoIcon1Click(Sender: TObject);
begin
cti.HideMainForm;
end;
procedure TWebM.ShowWindow1Click(Sender: TObject);
begin
cti.ShowMainForm;
end;
procedure TWebM.HideWindow1Click(Sender: TObject);
begin
cti.HideMainForm;
end;
procedure TWebM.Exit1Click(Sender: TObject);
begin
close;
end;
procedure TWebM.ctiMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var p:tpoint;
begin
getcursorpos(p);
popupmenu1.Popup(p.x,p.y);
end;
procedure TWebM.ExploreCurrentFolder1Click(Sender: TObject);
begin
strpcopy(loadbmp,'explorer '+filelistbox1.directory);
winexec(loadbmp,sw_shownormal);
end;
procedure TWebM.allClick(Sender: TObject);
var i:integer;
begin
chktemp(filelistbox1.directory,tempstr);
for i:=0 to filelistbox1.items.count-1 do
begin
listbox1.items.Add(tempstr+filelistbox1.items[i]);
listbox2.items.Add(tempstr+filelistbox1.items[i]);
end;
end;
procedure TWebM.Timer3Timer(Sender: TObject);
begin
if not intro.Down then
begin
timer3.Enabled:=false;
exit;
end;
if ms.CurrentPosition>=ms.Duration*strtofloat(cb1.text) then
if conm<filelistbox1.items.count-1 then
begin
conm:=conm+1;
chktemp(filelistbox1.directory,tempstr);
mediap(tempstr+filelistbox1.items[conm]);
end else
intro.Down:=false;
end;
procedure TWebM.FileListBox1Change(Sender: TObject);
begin
if filelistbox1.items.count>0 then
if filelistbox1.ItemIndex>=0 then
sm1.Enabled:=true else sm1.Enabled:=false;
if timer3.enabled then
begin
intro.Down:=false;
savb.enabled:=false;
ms.Stop;
end;
end;
procedure TWebM.introClick(Sender: TObject);
begin
conm:=0;
chktemp(filelistbox1.directory,tempstr);
if intro.Down then
begin
mediap(tempstr+filelistbox1.items[conm]);
timer3.enabled:=true;
end
end;
procedure TWebM.WindowsDesktop1Click(Sender: TObject);
begin
getwindowsdirectory(loadbmp,100);
chktemp(loadbmp,tempstr);
filelistbox1.Directory:=tempstr+'desktop';
end;
procedure TWebM.SaveList1Click(Sender: TObject);
begin
with Savedialog1 do
begin
Filename:='Untitled';
Filter:='Text File|*.txt';
DefaultExt:='txt';
title:='Saving Play List';
if Execute then
listbox1.Items.SaveToFile(filename);
end;
end;
procedure TWebM.OpenList1Click(Sender: TObject);
begin
with opendialog1 do
begin
Filename:='Untitled';
options:=[ofFileMustExist,ofEnableSizing];
title:='Open Play List' ;
Filter:='Text File|*.txt';
if Execute then
begin
listbox1.Items.LoadFromFile(filename);
listbox2.Items.LoadFromFile(filename);
end;
end;
end;
procedure TWebM.MediaPlayer1Notify(Sender: TObject);
begin
with Sender as TMediaPlayer do
begin
//Caption := ModeStr[Mode];
{ Note we must reset the Notify property to True }
{ so that we are notified the next time the }
{ mode changes }
Notify := True;
end;
end;
procedure TWebM.mediap(filen:string);
begin
if not fileexists(filen) then exit;
gb1.Caption:='Playing '+extractfilename(filen);
caption:='5,555 MP3 Music and Sound -'+extractfilename(filen);
ms.FileName:=filen;
ms.Play;
end;
procedure TWebM.chkcon;
begin
if not pb.Enabled and (listbox1.Items.Count>0) then
begin
if music<listbox1.items.count-1 then
music:=music+1 else
if repeatm.down then music:=0 else
begin
pb.tag:=0;
exit;
end;
if music<=listbox1.items.count-1 then
mediap(listbox1.items[music]);
end;
end;
procedure TWebM.sb1Scroll(Sender: TObject; ScrollCode: TScrollCode;
var ScrollPos: Integer);
begin
Case ScrollCode of
scTrack: ;//PosIsChangingNow:=true;
scEndScroll: begin
//PosIsChangingNow:=false;
// If (mp3.Mode=plmPlaying)or(mp3.Mode=plmPaused) then mp3.CurrentPosition:=ScrollPos;
// with mediaplayer1 do
// if (mode=mpplaying) or (mode=mppaused) then
// begin
//frames:=ScrollPos-position;
// position:=ScrollPos;
//caption:=inttostr(frames);
// play
// end;
end;
end;
end;
procedure TWebM.mp3PlayEnd(Sender: TObject);
begin
chkcon;
end;
procedure TWebM.ListBox1DblClick(Sender: TObject);
var i:integer;
begin
for i:=0 to listbox1.items.count-1 do
if listbox1.selected[i] then
mediap(listbox1.items[i]);
end;
procedure TWebM.savbClick(Sender: TObject);
begin
with Savedialog1 do
begin
FileName:='';
if filelistbox1.items.count>0 then
if filelistbox1.ItemIndex>=0 then
FileName:=filelistbox1.items[filelistbox1.ItemIndex];
if FileName='' then
begin
showmessage('Please select a media file from!');
exit;
end;
chktemp(filelistbox1.Directory,tempstr);
Filter:='Media File|*.wav;*.mid;*.cda;*.avi;*.mp*;';
title:='Saving Media File';
DefaultExt:='';
strpcopy(orifile,tempstr+filename);
if Execute then
begin
strpcopy(desfile,filename);
copyfile(orifile,desfile,false);
end;
end;
end;
procedure TWebM.CheckBox1Click(Sender: TObject);
begin
listbox1.Sorted:=checkbox1.Checked;
if not listbox1.Sorted then
listbox1.items:=listbox2.items;
end;
procedure TWebM.ListBox2Enter(Sender: TObject);
begin
listbox1.Items:=listbox2.items;
end;
procedure TWebM.ranClick(Sender: TObject);
var i,j,pk:integer;
begin
checkbox1.Checked:=false;
CheckBox1Click(Sender);
listbox1.Clear;
i:=0;
while i<listbox2.items.count do
begin
pk:=0;
tempstr:=listbox2.items[random(listbox2.items.count)];
for j:=0 to listbox1.items.Count-1 do
if listbox1.items[j]=tempstr then pk:=1;
//caption:=tempstr;
if pk=0 then
begin
listbox1.items.add(tempstr);
i:=i+1;
end;
end;
end;
procedure TWebM.SpeedButton7Click(Sender: TObject);
begin
with opendialog1 do
begin
Filename:='Untitled';
options:=[ofFileMustExist,ofEnableSizing];
title:='Open Media File' ;
Filter:='Media File|*.wav;*.mid;*.cda;*.mp*;';
if Execute then
mediap(filename);
end;
end;
procedure TWebM.Directory1Click(Sender: TObject);
begin
directory1.Checked:=not directory1.Checked;
panel2.visible:=directory1.Checked;
if panel2.Visible then fhd:=panel2.height else fhd:=0;
FormResize(Sender);
end;
procedure TWebM.Playlist1Click(Sender: TObject);
begin
playlist1.Checked:=not playlist1.Checked;
groupbox1.Visible:=playlist1.Checked;
if groupbox1.Visible then fhg:=groupbox1.height else fhg:=0;
FormResize(Sender);
end;
procedure TWebM.FormResize(Sender: TObject);
begin
height:=fphy+fhg+fhd;
end;
procedure TWebM.TheBestMusicMatch1Click(Sender: TObject);
begin
strpcopy(orifile,cur+'musicmat.exe');
winexec(orifile,sw_shownormal);
end;
procedure TWebM.MP3toWav1Click(Sender: TObject);
begin
showmessage('If you get a error message, please install "Windows Media Audio Driver".');
strpcopy(orifile,cur+'addons\conv\mp3conv.exe');
winexec(orifile,sw_shownormal);
end;
procedure TWebM.DirectoryListBox1Click(Sender: TObject);
begin
chktemp(directorylistbox1.Directory,tempstr);
try filelistbox1.directory:=tempstr+directorylistbox1.items[directorylistbox1.ItemIndex];
except end;
end;
procedure TWebM.cdfClick(Sender: TObject);
begin
with Savedialog1 do
begin
FileName:=filelistbox1.items[filelistbox1.ItemIndex];
chktemp(filelistbox1.Directory,tempstr);
strpcopy(orifile,tempstr+filename);
if not fileexists(masterdir+filelistbox1.items[filelistbox1.ItemIndex]) then
begin
strpcopy(desfile,masterdir+filename);
copyfile(orifile,desfile,false);
end else
begin
Filter:='Media File|*.wav;*.mid;*.cda;*.avi;*.mp*;';
title:='Saving Media File';
DefaultExt:='';
if Execute then
begin
strpcopy(desfile,filename);
copyfile(orifile,desfile,false);
end;
end;
end;
end;
procedure TWebM.SetDefaultFolder1Click(Sender: TObject);
begin
with opendialog1 do
begin
options:=[];
filename:='Select Directory and Click Open';
Title:='Select New Default Directory';
Filter:='';
if Execute then
masterdir:=extractfiledir(filename);
chktemp(masterdir,masterdir);
end;
end;
procedure TWebM.ExploreCD1Click(Sender: TObject);
begin
strpcopy(orifile,'explorer '+cur);
winexec(orifile,sw_shownormal);
end;
procedure TWebM.Readme1Click(Sender: TObject);
begin
strpcopy(orifile,'1.htm');
strpcopy(desfile,cur);
findexecutable(orifile,desfile,loadbmp);
tempstr:=' '+cur+'intro\1.htm';
strpcopy(orifile,loadbmp+tempstr);
winexec(orifile,sw_shownormal);
end;
procedure TWebM.cb1Change(Sender: TObject);
var i,j:integer;
begin
j:=-1;
for i:=0 to cb1.items.Count-1 do
if cb1.Text=cb1.items[i] then exit;
if j=-1 then cb1.Text:='.5';
end;
procedure TWebM.MediaPlayer2Click(Sender: TObject);
begin
strpcopy(orifile,cur+'media.exe');
winexec(orifile,sw_shownormal);
end;
procedure TWebM.FileListBox1Click(Sender: TObject);
begin
Timer3Timer(sender);
pb.Tag:=0;
chktemp(filelistbox1.Directory,tempstr);
mediap(tempstr+filelistbox1.items[filelistbox1.ItemIndex]);
end;
procedure TWebM.msEndOfStream(Sender: TObject; Result: Integer);
begin
chkcon;
end;
procedure TWebM.FormShow(Sender: TObject);
begin
if LowerCase(ParamStr(1))<>'' then
begin
showwindow1.Visible:=false;
hidewindow1.Enabled:=false;
menuitem1.Enabled:=false;
cti.StartMinimized:=true;
mediap(ParamStr(1));
windowstate:=wsMinimized;
end else
try
if (not fileexists(cur+'welcome.mp3')) or (ms.tag=99) then exit;
if ms.tag=0 then mediap(cur+'welcome.mp3');
ms.tag:=99;
except
showmessage('This system require MP3 Driver, click OK to install!'+chr(vk_return)+'Run this program again, after installation!');
winexec('media.exe',sw_shownormal);
end;
end;
procedure TWebM.msPlayStateChange(Sender: TObject; OldState,
NewState: Integer);
begin
cti.tag:=newstate;
end;
end.